package ltd.sshine.networkserver.holder;

import io.netty.channel.Channel;
import ltd.sshine.networkserver.handler.HttpProxyChannelHandler;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 代理服务器的持有者
 */
public class ProxyServerHolder {
    private static final Map<HttpProxyChannelHandler, Channel> connectHolder=new ConcurrentHashMap<>();

    public static void addChannel(HttpProxyChannelHandler id,Channel channel){
        connectHolder.put(id,channel);
    }
    public static void removeChannel(HttpProxyChannelHandler id){
        Channel remove = connectHolder.remove(id);
        remove.close();
        remove.eventLoop().shutdownGracefully();

    }
    public static Channel getChannel(HttpProxyChannelHandler id){
        return connectHolder.get(id);
    }
}
